/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.evl.tecinfo.gui;
import static br.com.evl.tecinfo.gui.CadastrarUsuario.ErroParaInt;
import static br.com.evl.tecinfo.gui.CadastrarUsuario.tb_edituser;
import br.com.evl.tecinfo.modelo.Area;
import br.com.evl.tecinfo.modelo.Cargo;
import br.com.evl.tecinfo.modelo.FormaDePagamento;
import br.com.evl.tecinfo.modelo.Funcionario;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
 *
 * @author Tecinfo
 */
public class Funcionarios extends javax.swing.JFrame {
        int linha = -1;
        int nada = 0;
        
        
    /**
     * Creates new form Funcionarios
     */

public static Object ErroParaInt(String conteudo) {
        try{
        int contint = Integer.parseInt(conteudo);
        while (contint <= 0 ){
            JOptionPane.showMessageDialog(null,"DIE POTATO", null,JOptionPane.INFORMATION_MESSAGE);
        }
        
        }catch (Exception e) {
             
            }
       
        return 0;
    } 
   
    public Funcionarios() {
        initComponents();
        
        jb_agencia.setVisible(false);
        jb_nomebanco.setVisible(false);
        jb_numerodaconta.setVisible(false);
        jb_valor.setVisible(false);
        ct_agenciaFuncionarios.setVisible(false);
        ct_nomedobancoFuncionarios.setVisible(false); 
        ct_numerodacontaFuncionarios.setVisible(false);
        ct_valorFuncionarios.setVisible(false);
        ct_valorValorFuncionarios.setVisible(false);
        jb_valorValor.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jl_cad_funcio = new javax.swing.JLabel();
        jb_remover = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jl_userform = new javax.swing.JLabel();
        jl_username = new javax.swing.JLabel();
        bt_cadastrar_usuario = new javax.swing.JButton();
        jla_usercpf = new javax.swing.JLabel();
        jl_area2 = new javax.swing.JLabel();
        cb_usereditform = new javax.swing.JComboBox();
        ct_usereditcpf = new javax.swing.JTextField();
        try{
            javax.swing.text.MaskFormatter cpf= new javax.swing.text.MaskFormatter("###.###.###-##");
            ct_usereditcpf = new javax.swing.JFormattedTextField(cpf);
        }
        catch (Exception e){
            JOptionPane.showMessageDialog(null,"Informe um CPF valido", null,JOptionPane.INFORMATION_MESSAGE);
        } 
        jl_uservalor = new javax.swing.JLabel();
        bt_limparuser = new javax.swing.JButton();
        bt_salvaruser = new javax.swing.JButton();
        jl_cargo2 = new javax.swing.JLabel();
        ct_usereditname = new javax.swing.JTextField();
        cb_usereditarea = new javax.swing.JComboBox();
        bt_edituser = new javax.swing.JButton();
        ct_usereditvalor = new javax.swing.JTextField();
        cb_usereditcargo = new javax.swing.JComboBox();
        jScrollPane3 = new javax.swing.JScrollPane();
        tb_edituser = new javax.swing.JTable();
        ct_nomedobancoFuncionarios = new javax.swing.JTextField();
        ct_agenciaFuncionarios = new javax.swing.JTextField();
        ct_numerodacontaFuncionarios = new javax.swing.JTextField();
        ct_valorFuncionarios = new javax.swing.JTextField();
        jb_nomebanco = new javax.swing.JLabel();
        jb_numerodaconta = new javax.swing.JLabel();
        jb_valor = new javax.swing.JLabel();
        jb_agencia = new javax.swing.JLabel();
        ct_valorValorFuncionarios = new javax.swing.JTextField();
        jb_valorValor = new javax.swing.JLabel();

        jl_cad_funcio.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jl_cad_funcio.setText("Cadastrar Funcionários");

        jb_remover.setText("Remover");
        jb_remover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_removerActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Tabela com a relação dos Funcionários Cadastrados");

        jl_userform.setText("Forma de Pagamento:");

        jl_username.setText("Nome:");

        bt_cadastrar_usuario.setText("Cadastrar");
        bt_cadastrar_usuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_cadastrar_usuarioActionPerformed(evt);
            }
        });

        jla_usercpf.setText("CPF:");

        jl_area2.setText("Área:");

        cb_usereditform.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar", "Cheque", "Dept. Bancário", "Dinheiro" }));
        cb_usereditform.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_usereditformActionPerformed(evt);
            }
        });

        jl_uservalor.setText("Valor da Hora Extra:");

        bt_limparuser.setText("Limpar");
        bt_limparuser.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                bt_limparuserMouseClicked(evt);
            }
        });
        bt_limparuser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_limparuserActionPerformed(evt);
            }
        });

        bt_salvaruser.setText("Atualizar dados");
        bt_salvaruser.setVisible(false);
        bt_salvaruser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_salvaruserActionPerformed(evt);
            }
        });

        jl_cargo2.setText("Cargo:");

        cb_usereditarea.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar", "Ed. Infantil", "Ens. Fundamental I", "Ens. Fundamental II", "Ens. Médio", "Serviço" }));

        bt_edituser.setText("Editar");
        bt_edituser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_edituserActionPerformed(evt);
            }
        });

        cb_usereditcargo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar", "Coordenador", "Professor", "Auxiliar" }));

        tb_edituser.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome", "CPF", "Cargo", "Area", "Valor hora extra", "Forma de pagamento"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tb_edituser.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        tb_edituser.setDragEnabled(true);
        tb_edituser.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane3.setViewportView(tb_edituser);

        jb_nomebanco.setText("Nome do banco:");

        jb_numerodaconta.setText("Numero da conta:");

        jb_valor.setText("Valor:");

        jb_agencia.setText("Agencia:");

        ct_valorValorFuncionarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ct_valorValorFuncionariosActionPerformed(evt);
            }
        });

        jb_valorValor.setText("Valor");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jl_cad_funcio, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(359, 359, 359)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 542, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jl_username)
                                        .addGap(10, 10, 10)
                                        .addComponent(ct_usereditname, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jla_usercpf)
                                        .addGap(18, 18, 18)
                                        .addComponent(ct_usereditcpf, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jl_cargo2)
                                        .addGap(10, 10, 10)
                                        .addComponent(cb_usereditcargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jl_area2)
                                        .addGap(18, 18, 18)
                                        .addComponent(cb_usereditarea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jl_uservalor)
                                        .addGap(10, 10, 10)
                                        .addComponent(ct_usereditvalor, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jb_nomebanco)
                                        .addGap(18, 18, 18)
                                        .addComponent(ct_nomedobancoFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jb_agencia)
                                        .addGap(10, 10, 10)
                                        .addComponent(ct_agenciaFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jl_userform)
                                        .addGap(4, 4, 4)
                                        .addComponent(cb_usereditform, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(32, 32, 32)
                                        .addComponent(jb_valorValor)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(ct_valorValorFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(149, 149, 149)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 407, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jb_numerodaconta)
                                .addGap(10, 10, 10)
                                .addComponent(ct_numerodacontaFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(32, 32, 32)
                                .addComponent(jb_valor)
                                .addGap(24, 24, 24)
                                .addComponent(ct_valorFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(bt_cadastrar_usuario, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addComponent(bt_limparuser)
                        .addGap(37, 37, 37)
                        .addComponent(bt_edituser)
                        .addGap(8, 8, 8)
                        .addComponent(bt_salvaruser)
                        .addGap(38, 38, 38)
                        .addComponent(jb_remover, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(511, 511, 511))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jl_cad_funcio, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jl_username))
                            .addComponent(ct_usereditname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jla_usercpf))
                            .addComponent(ct_usereditcpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jl_cargo2))
                            .addComponent(cb_usereditcargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jl_area2))
                            .addComponent(cb_usereditarea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(17, 17, 17)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jl_uservalor))
                            .addComponent(ct_usereditvalor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jl_userform))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cb_usereditform, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(ct_valorValorFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jb_valorValor)))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addComponent(jb_nomebanco))
                            .addComponent(ct_nomedobancoFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jb_agencia))
                            .addComponent(ct_agenciaFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ct_numerodacontaFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ct_valorFuncionarios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jb_numerodaconta)
                            .addComponent(jb_valor))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(bt_cadastrar_usuario)
                    .addComponent(bt_limparuser)
                    .addComponent(bt_edituser)
                    .addComponent(bt_salvaruser)
                    .addComponent(jb_remover))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jb_removerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_removerActionPerformed
        // TODO add your handling code here:
        DefaultTableModel dtm = (DefaultTableModel) tb_edituser.getModel();

        int linha = tb_edituser.getSelectedRow();
        Object[] dados = {ct_usereditname.getText(), ct_usereditcpf.getText(), cb_usereditarea.getSelectedItem(),ct_usereditvalor.getText(), cb_usereditcargo.getSelectedItem(), cb_usereditform.getSelectedItem()};

        dtm.removeRow(linha);
        JOptionPane.showMessageDialog(null, "Funcionário removido com sucesso!");
    }//GEN-LAST:event_jb_removerActionPerformed

    private void bt_cadastrar_usuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_cadastrar_usuarioActionPerformed
        // TODO add your handling code here:
        if (linha == -1) {
            /*try {*/
                if(nada == 2) {

                }

                String erro1 = ct_usereditvalor.getText();
                ErroParaInt(erro1);
                

                /*String erro2 = ct_usereditname.getText();
                 * ErroParaString(erro2);*/
                
                /*String erros = "";
                * ErroParaInt (erros);*/
                if (ct_usereditname.getText().equals("") || ct_usereditvalor.getText().equals("") || ct_usereditcpf.getText().equals("")){
                    JOptionPane.showMessageDialog(null, "Preencha os campos corretamente", null, JOptionPane.ERROR_MESSAGE);

                }/*else if (ct_usereditvalor.getText().equals(erros) || ct_usereditcpf.getText().equals(erros)) {
                    * JOptionPane.showMessageDialog(null, "DIE POTATO", null, JOptionPane.ERROR_MESSAGE);
                    *
                    * }*/else if(cb_usereditcargo.getSelectedIndex() == 0 || cb_usereditarea.getSelectedIndex() == 0 || cb_usereditform.getSelectedIndex() == 0 ) {
                    JOptionPane.showMessageDialog(null, "Preencha os campos corretamente", null, JOptionPane.ERROR_MESSAGE);

                }else{
                    int confirmacao = JOptionPane.showConfirmDialog(null,"Deseja prosseguir com a operação?",null,JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
                    if (confirmacao == JOptionPane.YES_OPTION){
                        JOptionPane.showMessageDialog(null,"Paciente cadastrado com sucesso!",null,JOptionPane.INFORMATION_MESSAGE);
                        //JOptionPane.showMessageDialog(null, "Não pode deixar nada em branco!", null, JOptionPane.ICON_PROPERTY);
                         Cargo novo_cargo = new Cargo((String) cb_usereditcargo.getSelectedItem(), 0);
                        FormaDePagamento novo_formpagamento = new FormaDePagamento(0, "Nome do Funcionario","Nome do Banco", "Numero da Conta", "Cheque", 8);
                        Area nova_area = new Area("Nome", "Abrev", 0);
                        float ValorHoraExtra = Float.parseFloat(ct_usereditvalor.getText());
                        Funcionario novo_funcionario = new Funcionario (ct_usereditname.getText(), novo_cargo ,ct_usereditcpf.getText(), nova_area, ValorHoraExtra ,novo_formpagamento );
                
                        DefaultTableModel dtm = (DefaultTableModel) tb_edituser.getModel();
                        Object[] opcoes = {ct_usereditname.getText(), ct_usereditcpf.getText(), cb_usereditcargo.getSelectedItem(), cb_usereditarea.getSelectedItem(),ct_usereditvalor.getText(), cb_usereditform.getSelectedItem()};
                        dtm.addRow(opcoes);

                        ct_usereditname.setText("");
                        ct_usereditcpf.setText("");
                        cb_usereditarea.setSelectedIndex(0);
                        ct_usereditvalor.setText("");
                        cb_usereditform.setSelectedIndex(0);
                        cb_usereditcargo.setSelectedIndex(0);
                         tb_edituser.clearSelection();
                        linha = -1;
                       

                    }

                }

                /*} catch (Exception e) {
                * JOptionPane.showMessageDialog(null,"Forneça apenas números naturais.",null,JOptionPane.INFORMATION_MESSAGE);
                *
                * }*/
        }
    }//GEN-LAST:event_bt_cadastrar_usuarioActionPerformed

    private void bt_limparuserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bt_limparuserMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_bt_limparuserMouseClicked

    private void bt_limparuserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_limparuserActionPerformed
        // TODO add your handling code here:
        ct_usereditname.setText("");
        ct_usereditcpf.setText("");
        cb_usereditarea.setSelectedIndex(0);
        ct_usereditvalor.setText("");
        cb_usereditform.setSelectedIndex(0);
        cb_usereditcargo.setSelectedIndex(0);
    }//GEN-LAST:event_bt_limparuserActionPerformed

    private void bt_salvaruserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_salvaruserActionPerformed
        // TODO add your handling code here:

        if (linha != -1){

            if (ct_usereditname.getText().equals("") || ct_usereditvalor.getText().equals("") || ct_usereditcpf.getText().equals("")){
                JOptionPane.showMessageDialog(null, "Preencha os campos corretamente", null, JOptionPane.ERROR_MESSAGE);

            }else if(cb_usereditcargo.getSelectedIndex() == 0 || cb_usereditarea.getSelectedIndex() == 0 || cb_usereditform.getSelectedIndex() == 0 ) {
                JOptionPane.showMessageDialog(null, "Preencha os campos corretamente", null, JOptionPane.ERROR_MESSAGE);

            }else{
                // DefaultTableModel dtm = (DefaultTableModel) tb_tabela.getModel();
                //Object[] opcoes = {ct_nome.getText(), ct_endereco.getText(), ct_cpf.getText(), ct_idade.getText(), cb_selecao.getSelectedItem()};
                tb_edituser.setValueAt(ct_usereditname.getText(),linha,0);
                tb_edituser.setValueAt(ct_usereditcpf.getText(),linha,1);
                tb_edituser.setValueAt(cb_usereditcargo.getSelectedItem(),linha,2);
                tb_edituser.setValueAt(cb_usereditarea.getSelectedItem(),linha,3);
                tb_edituser.setValueAt(ct_usereditvalor.getText(),linha,4);
                tb_edituser.setValueAt(cb_usereditform.getSelectedItem(),linha,5);
                int confirmacao = JOptionPane.showConfirmDialog(null,"Deseja prosseguir com a operação?",null,JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
                if (confirmacao == JOptionPane.YES_OPTION){
                    JOptionPane.showMessageDialog(null,"Atualização feita com sucesso!",null,JOptionPane.INFORMATION_MESSAGE);
                    Cargo novo_cargo = new Cargo((String) cb_usereditcargo.getSelectedItem(), 0);
                    FormaDePagamento novo_formpagamento = new FormaDePagamento(0, "Nome do Funcionario","Nome do Banco", "Numero da Conta", "Cheque", 8);
                    Area nova_area = new Area("Nome", "Abrev", 0);
                    float ValorHoraExtra = Float.parseFloat(ct_usereditvalor.getText());
                    Funcionario novo_funcionario = new Funcionario (ct_usereditname.getText(), novo_cargo ,ct_usereditcpf.getText(), nova_area, ValorHoraExtra ,novo_formpagamento );
            
                }
                ct_usereditname.setText("");
                ct_usereditcpf.setText("");
                cb_usereditarea.setSelectedIndex(0);
                ct_usereditvalor.setText("");
                cb_usereditform.setSelectedIndex(0);
                cb_usereditcargo.setSelectedIndex(0);
                tb_edituser.clearSelection();
                linha = -1;
                tb_edituser.clearSelection();
                nada = 0;
                bt_salvaruser.setVisible(false);
                bt_cadastrar_usuario.setVisible(true);
            }
        }
    }//GEN-LAST:event_bt_salvaruserActionPerformed

    private void bt_edituserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_edituserActionPerformed
        // TODO add your handling code here:
        // Editar(linha);
            
              linha = tb_edituser.getSelectedRow();
            if (linha != -1 ) {
            
            bt_salvaruser.setVisible(true);
            bt_cadastrar_usuario.setVisible(false);
            ct_usereditname.setText((String) tb_edituser.getValueAt(linha, 0));
            ct_usereditcpf.setText((String)tb_edituser.getValueAt(linha,1));
            cb_usereditcargo.setSelectedItem((String)tb_edituser.getValueAt(linha, 2));
            cb_usereditarea.setSelectedItem((String) tb_edituser.getValueAt(linha, 3));
            ct_usereditvalor.setText((String) tb_edituser.getValueAt(linha, 4));
            cb_usereditform.setSelectedItem((String) tb_edituser.getValueAt(linha, 5));
                
            }
           
      
    }//GEN-LAST:event_bt_edituserActionPerformed

    private void cb_usereditformActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_usereditformActionPerformed
        // TODO add your handling code here:
        if (cb_usereditform.getSelectedItem().equals("Dept. Bancário")){
        jb_agencia.setVisible(true);
        jb_nomebanco.setVisible(true);
        jb_numerodaconta.setVisible(true);
        jb_valor.setVisible(true);
        ct_agenciaFuncionarios.setVisible(true);
        ct_nomedobancoFuncionarios.setVisible(true); 
        ct_numerodacontaFuncionarios.setVisible(true);
        ct_valorFuncionarios.setVisible(true);
        
    }else if (cb_usereditform.getSelectedItem().equals("Dept. Bancário") || cb_usereditform.getSelectedItem().equals("Cheque") || cb_usereditform.getSelectedItem().equals("Selecionar") ){ 
        jb_agencia.setVisible(false);
        jb_nomebanco.setVisible(false);
        jb_numerodaconta.setVisible(false);
        jb_valor.setVisible(false);
        ct_agenciaFuncionarios.setVisible(false);
        ct_nomedobancoFuncionarios.setVisible(false); 
        ct_numerodacontaFuncionarios.setVisible(false);
        ct_valorFuncionarios.setVisible(false);
        ct_valorValorFuncionarios.setVisible(false);
        jb_valorValor.setVisible(false);
        
    }else if (cb_usereditform.getSelectedItem().equals("Dinheiro")){
       ct_valorValorFuncionarios.setVisible(true);
       jb_valorValor.setVisible(true);
       jb_agencia.setVisible(false);
        jb_nomebanco.setVisible(false);
        jb_numerodaconta.setVisible(false);
        jb_valor.setVisible(false);
        ct_agenciaFuncionarios.setVisible(false);
        ct_nomedobancoFuncionarios.setVisible(false); 
        ct_numerodacontaFuncionarios.setVisible(false);
        ct_valorFuncionarios.setVisible(false);
       
    }
        
    }//GEN-LAST:event_cb_usereditformActionPerformed

    private void ct_valorValorFuncionariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ct_valorValorFuncionariosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ct_valorValorFuncionariosActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Funcionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Funcionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Funcionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Funcionarios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Funcionarios().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bt_cadastrar_usuario;
    public static javax.swing.JButton bt_edituser;
    private javax.swing.JButton bt_limparuser;
    private javax.swing.JButton bt_salvaruser;
    private javax.swing.JComboBox cb_usereditarea;
    private javax.swing.JComboBox cb_usereditcargo;
    private javax.swing.JComboBox cb_usereditform;
    private javax.swing.JTextField ct_agenciaFuncionarios;
    private javax.swing.JTextField ct_nomedobancoFuncionarios;
    private javax.swing.JTextField ct_numerodacontaFuncionarios;
    private javax.swing.JTextField ct_usereditcpf;
    private javax.swing.JTextField ct_usereditname;
    private javax.swing.JTextField ct_usereditvalor;
    private javax.swing.JTextField ct_valorFuncionarios;
    private javax.swing.JTextField ct_valorValorFuncionarios;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JLabel jb_agencia;
    private javax.swing.JLabel jb_nomebanco;
    private javax.swing.JLabel jb_numerodaconta;
    private javax.swing.JButton jb_remover;
    private javax.swing.JLabel jb_valor;
    private javax.swing.JLabel jb_valorValor;
    private javax.swing.JLabel jl_area2;
    private javax.swing.JLabel jl_cad_funcio;
    private javax.swing.JLabel jl_cargo2;
    private javax.swing.JLabel jl_userform;
    private javax.swing.JLabel jl_username;
    private javax.swing.JLabel jl_uservalor;
    private javax.swing.JLabel jla_usercpf;
    public static javax.swing.JTable tb_edituser;
    // End of variables declaration//GEN-END:variables
}
